function a(a) {
    return new Promise(function(a, t) {
        wx.getLocation({
            type: "gcj02",
            success: function(t) {
                a(t);
            },
            fail: function() {
                t();
            }
        });
    });
}

function t(a, t) {
    return new Promise(function(n, i) {
        wx.getLocation({
            success: function(o) {
                o.latitude, o.longitude;
                if (wx.setStorage({
                    key: "latlng",
                    data: {
                        lat: o.latitude,
                        lng: o.longitude
                    }
                }), "" === o) {
                    var s = t.getSecret();
                    wx.request({
                        url: t.globalData.haozuBase + "/api/miniapps/getcity/",
                        data: {
                            currtime: s.currtime,
                            sign: s.sign
                        },
                        success: function(a) {
                            200 === a.data.code ? n(a.data.data.domain) : i("bj");
                        }
                    });
                } else e(a, t, o).then(function(e) {
                    "" !== e ? (t.globalData.domain = e, n(e), a.setData({
                        domain: e
                    })) : i("bj");
                }, function(e) {
                    t.globalData.domain = e, a.setData({
                        domain: e
                    });
                });
            },
            fail: function(a) {
                i("bj");
            }
        });
    });
}

function e(a, t, e) {
    return new Promise(function(a, n) {
        wx.getLocation({
            success: function(i) {
                var o = t.getSecret();
                wx.request({
                    url: t.globalData.haozuBase + "/api/miniapps/getcity/",
                    data: {
                        currtime: o.currtime,
                        sign: o.sign,
                        lat: e.latitude,
                        lng: e.longitude
                    },
                    success: function(t) {
                        a(t.data.data.domain);
                    },
                    fail: function(a) {
                        n("bj");
                    }
                });
            }
        });
    });
}

var n = getApp(), i = require("../../utils/icon.js");

Page({
    data: {
        domain: "bj",
        citys: [],
        motto: "Hello World",
        userInfo: {},
        hasUserInfo: !1,
        canIUse: wx.canIUse("button.open-type.getUserInfo"),
        list_name: [],
        building_items: [],
        house_type: [],
        msg_template: "",
        showYK: !1,
        shade: !1,
        subsucc: !1,
        hasError: !1,
        resPhone: "",
        isYK: !1,
        building: {},
        demo: {},
        lat: "",
        lng: "",
        show_place: [],
        loginYK: !0,
        close: i.close,
        animationData: {},
        rmove: "",
        navigator: [],
        imgUrls: [ "https://fang-oss.haozu.com/cms/index/2018/04/19/E7Fy5x6cdM.jpg@750w_500h_90q_1c_1e_1" ],
        array: ['美国', '中国', '巴西', '日本'],
        index: 0,
        navTab: ['全部订单','待付款','待发货', '待收货','全部订单','待付款','待发货', '待收货'],        
        currentTab: 0,
        sendList:[],
    },
    bindViewTap: function() {
        wx.navigateTo({
            url: "../logs/logs"
        });
    },
    intap: function(a) {},
    showFn: function() {
        var a = this;
        wx.makePhoneCall({
            phoneNumber: a.data.msg_template
        });
    },
    clickFun: function(a) {
        new Promise(function(a, t) {
            wx.request({
                url: n.globalData.haozuBase + "/bj/cooperation/ganji/",
                data: {
                    city_id: "12",
                    district_id: "173",
                    street_id: "793",
                    page_size: "5"
                },
                success: function(t) {
                    a(t);
                }
            });
        }).then(function(a) {}, function(a) {}).catch(function(a) {});
    },
    outap: function(a) {},
    onLoad: function(a) {
        var e = this, i = this;
        if (a.scene) {
            for (var o = decodeURIComponent(a.scene).split("&"), s = {}, u = 0; u < o.length; u++) {
                var l = o[u].split("=");
                s[l[0]] = l[1];
            }
            n.globalData["tel-phone"] = s.m;
        }
        a.domain ? (n.globalData.domain = a.domain, i.setData({
            domain: n.globalData.domain
        })) : (wx.showToast({
            icon: "none",
            title: "城市定位中~",
            mask: !0
        }), t(i, n).then(function(a) {
            wx.hideToast(), n.globalData.domain = a, i.setData({
                domain: a
            });
        }, function(a) {
            wx.hideToast(), n.globalData.domain = a, i.setData({
                domain: a
            });
        })), n.globalDataLoad(i, "citys"), n.globalDataLoad(i, "tel-phone", "msg_template");
        n.getSecret();
        var r = n.globalData.userInfo || {};
        r && r.mobile && i.setData({
            isDis: !0,
            resPhone: r.mobile,
            loginYK: !1,
            isYK: !0
        }), n.globalData.userInfo ? this.setData({
            userInfo: n.globalData.userInfo,
            resPhone: n.globalData.userInfo.mobile || "",
            hasUserInfo: !0
        }) : this.data.canIUse ? n.userInfoReadyCallback = function(a) {
            e.setData({
                userInfo: a.userInfo,
                resPhone: n.globalData.userInfo.mobile,
                hasUserInfo: !0
            });
        } : wx.getSetting({
            success: function(a) {
                n.globalData.userInfo = a.userInfo, e.setData({
                    userInfo: a.userInfo,
                    resPhone: n.globalData.userInfo.mobile,
                    hasUserInfo: !0
                });
            }
        });
        var c = wx.getStorageSync("latlng");
        console.log(c), 1 == a.citylist ? wx.request({
            url: n.globalData.haozuBase + "/api/miniapps/getcity/?domain=" + a.domain,
            data: Object.assign(c, n.getSecret()),
            success: function(a) {
                var t = a.data.data.menu, e = t;
                for (i.setData({
                    navigator: e
                }), u = 0; u < t.length; u++) if (t[u].url) {
                    var n = {
                        dataurl: t[u].url
                    };
                    wx.setStorageSync("developer", n);
                }
            }
        }) : wx.request({
            url: n.globalData.haozuBase + "/api/miniapps/getcity/",
            data: Object.assign(c, n.getSecret()),
            success: function(a) {
                console.log(a.data);
                var t = a.data.data.menu, e = t;
                for (i.setData({
                    navigator: e
                }), u = 0; u < t.length; u++) if (t[u].url) {
                    var n = {
                        dataurl: t[u].url
                    };
                    wx.setStorageSync("developer", n);
                }
            }
        });
    },
    bindGetUserInfo: function(a) {},
    onReady: function() {
        var t = this, e = n.getSecret();
        a().then(function(a) {
            wx.request({
                url: n.globalData.haozuBase + "/api/miniapps/getindexlist/",
                data: {
                    domain: t.data.domain,
                    lat: a.latitude,
                    lng: a.longitude,
                    currtime: e.currtime,
                    sign: e.sign,
                    type: 2
                },
                success: function(a) {
                    var e = a.data, n = e.data, i = [];
                    for (var o in n.list) i.push(n.list[o]);
                    t.setData({
                        building_items: i,
                        show_place: e.data.show_place || ""
                    });
                }
            });
        }, function() {
            wx.request({
                url: n.globalData.haozuBase + "/api/miniapps/getindexlist/",
                data: {
                    domain: t.data.domain,
                    currtime: e.currtime,
                    sign: e.sign,
                    type: 2
                },
                success: function(a) {
                    var e = a.data, n = e.data, i = [];
                    for (var o in n.list) i.push(n.list[o]);
                    t.setData({
                        building_items: i,
                        show_place: e.data.show_place
                    });
                }
            });
        });
    },
    refresh: function() {
        var t = this, e = n.getSecret();
        t.setData({
            rmove: "dmove"
        }), setTimeout(function() {
            t.setData({
                rmove: ""
            });
        }, 1200), a().then(function(a) {
            wx.request({
                url: n.globalData.haozuBase + "/api/miniapps/getindexlist/",
                data: {
                    domain: t.data.domain,
                    lat: a.latitude,
                    lng: a.longitude,
                    currtime: e.currtime,
                    sign: e.sign,
                    type: 2
                },
                success: function(a) {
                    var e = a.data, n = e.data, i = [];
                    for (var o in n.list) i.push(n.list[o]);
                    t.setData({
                        building_items: i,
                        show_place: e.data.show_place
                    });
                }
            });
        }, function() {});
        var i = wx.createAnimation({
            duration: 1e3,
            timingFunction: "ease"
        });
        t.animation = i, t.setData({
            animationData: i.export()
        }), i.rotate(360).step(), setTimeout(function() {
            i.rotate(0).step({
                duration: 0,
                transformOrigin: "50%,50%",
                timingFunction: "linear"
            }), t.setData({
                animationData: i.export()
            });
        }, 300);
    },
    getUserInfo: function(a) {
        n.globalData.userInfo = a.detail.userInfo, this.setData({
            userInfo: a.detail.userInfo,
            hasUserInfo: !0
        });
    },
    onShareAppMessage: function(a) {
        return {
            title: "办公选址上好租，专业靠谱",
            desc: "办公选址上好租，专业靠谱",
            path: "/pages/index/index?share=1&domain=" + n.globalData.domain
        };
    },
    onShow: function() {
        n.globalDataLoad(this, "tel-phone", "msg_template"), null !== n.globalData.userInfo && this.setData({
            show: !1,
            phone: n.globalData.userInfo.mobile || ""
        });
    },
    inputChange: function(a) {
        this.setData({
            resPhone: a.detail.value
        });
    },
    submitYK: function(a) {
        var t = this, e = /^(13[0-9]|14[5|7]|15[0-9]|17[0|1|3|5|6|7|8]|18[0-9])\d{8}$/, i = t.data.resPhone;
        return !t.data.isYK && (e.test(i) ? (t.setData({
            hasError: !1
        }), void n.orderlogin({
            mobile: i,
            name: "小程序楼盘页预约",
            building_id: t.data.building.id,
            building_name: t.data.building.name,
            from_page: 2
        }).then(function(a) {
            200 == a.code && (t.setData({
                showYK: !1,
                subsucc: !0,
                isYK: !0
            }), setTimeout(function() {
                t.setData({
                    showYK: !1,
                    subsucc: !1
                });
            }, 3e3));
        })) : (t.setData({
            hasError: !0
        }), !1));
    },
    Ylogin: function() {
        wx.navigateTo({
            url: "/pages/login/index?phone=" + this.data.resPhone
        }), this.setData({
            shade: !1,
            subsucc: !1
        });
    },
    closePop: function() {
        this.setData({
            shade: !1,
            subsucc: !1
        });
    },
    toMyFn: function() {
        wx.reLaunch({
            url: "/pages/my/index"
        });
    },
    onReachBottom: function() {
        wx.navigateTo({
            url: "/pages/list/list_house?domain=" + this.data.domain
        });
    }
});